<div class="shop_sell_but">
    <div class="box_but">
        <form action="{:U('Cart/create')}" id="cart_form" method="post">
            <input type="hidden" value="{$datainfo.good_id}" name="good_id"/><input type="hidden" value="0" name="gobuy" id="gobuy"/>
            <ul>
                <volist name="datainfo.attr" id="atvo" key="ati">
                    <li class="good_attr">
                        <strong>{$atvo.label}：</strong>
                        <php>
                            $atvolist = explode("|", $atvo['values']);
                        </php>
                        <volist name="atvolist" id="aat" key="ak">
                            <eq name="ak" value="1">
                                <input type="hidden" name="good_attr[]" id="attr_{$ati}" value="{$atvo.label}:{$aat}"><a href="#nogo" class="p_size" rel="attr_{$ati}" id="attr_{$ati}_{$ak}" data="{$atvo.label}:{$aat}"><span>{$aat}</span><i>已选中</i></a>
                                <else/><a href="#nogo" class="p_size_no" rel="attr_{$ati}" id="attr_{$ati}_{$ak}" data="{$atvo.label}:{$aat}">{$aat}</a>
                            </eq>
                        </volist>
                    </li>
                </volist>
                <li>
                    <strong>我 要 买：</strong>
                    <input name="good_num" value="1" type="text" class="sr vm" />件 (库存{$datainfo.number}件)
                </li>
            </ul>
        </form><a href="#nogo" class="gs mr" onclick="gotoBuy();">立刻购买</a>
        <a href="#nogo" class="gc" onclick="addtoCart();">加入购物车</a>
    </div>
</div>
<script>
   	 /*
     * ******************************************************
     * 购买商品时选择立刻购买
     * ******************************************************
     */
    function gotoBuy(){
        var member_id = '{@member_id}';
        if (member_id == '') {
            //show_login();
            //return false;
        }
        //$('#gobuy').val('1');
        postForm('cart_form',function(jdata){
			if (jdata.status == 1) {
              go2('{:U('Orderform/create')}');
	        }
	        else {
	          alert(jdata.info);
	        }
		});
    }
    
    /*
     * ******************************************************
     * 购买商品时选择加入购物车
     * ******************************************************
     */
    function addtoCart(){
        var member_id = '{@member_id}';
        if (member_id == '') {
            //show_login();
            //return false;
        }
        postForm('cart_form', function(jdata){
			if (jdata.status) {
				//alert(jdata.info);
	            $('#good_num_box').html(jdata.data.good);
	            $('#good_price_box').html(jdata.data.price);
	            $('#J_CartInfo').show();
	        }
	        else {
	            alert(jdata.info);
	            //go2();
	        }
		});
    }
</script>
